enum DIR{LEFT,RIGHT}
public class BinaryTreeTest {
    public static void main(String[] args) {
        BalancedTree<Integer> tree=new BalancedTree<>();
        tree.insert(8);
    }
}

class BalancedTree<E extends Comparable<E> > {
    private BalancedTreeNode<E> root;

    public BalancedTree(BalancedTreeNode<E> root) {
    }

    public BalancedTree() {
        this(null);
    }

    public BalancedTreeNode<E> getRoot() {
        return root;
    }

    public void insert(E element) {
        if(root==null){
            root=new BalancedTreeNode<E>(element,null);
        }else{
            root.addNode(element);
        }
    }

    public void adjust(){

    }

}
record SubNode<E extends Comparable<E>>
        (BalancedTreeNode<E> parent, DIR d, int depth){
}


class BalancedTreeNode<E extends Comparable<E>> {
    final E data;
    BalancedTreeNode<E> left, right, parent;

    int leftDepth() {
        if (left == null) {
            return 0;
        }
        return Math.max(left.leftDepth(), left.rightDepth());
    }

    int rightDepth() {
        if (right == null) {
            return 0;
        }
        return Math.max(right.leftDepth(), right.rightDepth());
    }

    BalancedTreeNode(E data, BalancedTreeNode<E> parent) {
        this.data = data;
        this.parent = parent;
        left = right = null;
    }

    public E getData() {
        return data;
    }

    public void addNode(E data) {
        if(data==null)return;
        if(data.compareTo(this.data)==0)return;
        if(data.compareTo(this.data)>0)
        {
            if(left==null){
                left=new BalancedTreeNode<>(data,this);
            }else{
                left.addNode(data);
            }
        }else{
            if(right==null){
                right=new BalancedTreeNode<>(data,this);
            }
            else {
                right.addNode(data);
            }
        }
    }

}